<template>
    <s-table ref="tableRef" :data="loadData"  :scroll="{ x: 1400, }"  :columns="columns" :pagination="false" class="mb-2">
        <template #bodyCell="{ column, record, index }">
            <template v-if="column.key === 'index'">
                {{ index + 1 }}
            </template>
        </template>
    </s-table>
</template>

<script setup name="invitebid">
import api from '@/api/contract/purchase/index'
const props = defineProps({
    proId: {
        type: String,
    },
})
const { proId } = toRefs(props)

const columns = [
    {
        title: '序号',
        dataIndex: 'index',
        key: 'index',
        width: 50, 
        align: 'center'
    },
    {
        title: "合同编号",
        dataIndex: "code",
        key: "code",
        width: 180, 
        align: 'center'
    },
    {
        title: '合同名称',
        dataIndex: 'name',
        key: 'name',
        width: 180, 
        align: 'center'
    },
    {
        title: "供应商名称",
        dataIndex: "supplierId",
        key: "supplierId",
        width: 100, 
        align: 'center'
    }, {
        title: '是否收到原件',
        dataIndex: 'original',
        key: 'original',
        width: 120, 
        align: 'center'
    },
    {
        title: '采购负责人',
        dataIndex: 'director',
        key: 'director',
        width: 100, 
        align: 'center'
    }, {
        title: '所属部门 ',
        dataIndex: 'orgName',
        key: 'orgName',
        width: 100, 
        align: 'center'
    },
    //  {
    //     title: ' 所属公司 ',
    //     dataIndex: 'company',
    //     key: 'company',
    //     width: 100, 
    //     align: 'center'
    // },
    
    {

        title: " 合同金额 ",
        dataIndex: "amount",
        key: "amount",
        width: 100, 
        align: 'center'
    }, {
        title: "已付金额 ",
        dataIndex: "paidAmount",
        key: "paidAmount",
        width: 100, 
        align: 'center'
    }, {
        title: "未付金额 ",
        dataIndex: "unpaidAmount",
        key: "unpaidAmount",
        width: 100, 
        align: 'center'
    },
    {
        title: "签订时间",
        dataIndex: "signTime",
        key: "signTime",
        width: 150, 
        align: 'center'
    },
]
 
const tableRef = ref()
const loadData = (parameter) => {
    const searchFormState = ref({
        proId: proId
    })
    searchFormState.value.current = parameter.current
    searchFormState.value.size = parameter.size
    return api.page(searchFormState.value).then((res) => {
        return res
    })
}


watch(
    () => props.proId,
    (newVal, oldVal) => {
        if (newVal) {
            nextTick(() => {
                tableRef.value.refresh(true)
            })
        }
    },
    { deep: true, immediate: true }
)


</script>
